home *** CD-ROM | disk | FTP | other *** search
- /*
- * CSignature.h
- * Copyright © 1993 Apple Computer Inc.
- * All Rights Reserved
- *
- * This is a Think C class library definition that simplifies
- * access to the AOCE Digital Signature Manager. CSignature
- * is a base class; your applications access it through
- * one of the subclasses: CSignedDataFile to sign or verify
- * a file (as created/used by a CDocument subclass) or
- * CSignedObject to sign or verify an object.
- *
- * Errors are returned through the Think Class
- * Library "Failure" routines.
- *
- * If you specify gSIGStatusProc as the status procedure
- * to a sign or verify operation, a default status window
- * will be displayed.
- *
- * Note that there is only one, global, signature context
- * for the entire application. Also note that your
- * application must ensure that the context is deleted
- * before exiting. If you are running under the
- * Think Class Library, the RemovePatches CApplication
- * method must be subclassed to do this (see DemoApp.c).
- * If you have translated this to some other environment,
- * you must patch ExitToShell to remove the context.
- */
-
- #define _H_CSignature
- /*
- * A.O.C.E. header files.
- */
- #include <DigitalSignature.h>
- /*
- * TCL header files.
- */
- #include <CObject.h>
-
- /*
- *** Global values and procedures.
- */
- /*
- * gSIGStatusProc is a callback procedure that
- * the Digital Signature Manager calls while
- * signing or verifying data. If you pass
- * this value as the statusProc parameter,
- * a default status window will be shown.
- */
- pascal Boolean gSIGStatusProc(void);
-
- /*
- * gSIGContextPtr contains the information the DigitalSignature
- * Manager needs to organize the signature and verification
- * operations. Note that is an application-wide global. This is
- * so that it is always deleted when the application exits.
- */
- extern SIGContextPtr gSIGContextPtr;
- /*
- * DisposeContext disposes of the current signature context
- * (freeing memory and releasing the Digital Signature Manager
- * functions from memory) It does not dispose of the object
- * or any signature. It is called automatically by Dispose,
- * Sign and SignFile, but not by Verify and VerifyFile (as
- * the context is needed by ShowSigner and the other
- * certificate information methods. Calling it when there
- * is no signer context does not cause any errors.
- */
- void DisposeSignerContext(void);
-
- /*
- * The sample application has a STR# resource with three
- * strings that are used by the default status procedure.
- */
- enum {
- STRn_SIGStatusProc = 1024, /* STR# resource: */
- kStatusSignString = 1, /* "Signing " */
- kStatusVerifyString, /* "Verifying " */
- kStatusDataString /* "data." */
- };
-
- /*
- *** Externally-referenced classes.
- */
- class CDataFile;
- class SIGStatusManager;
-
- /*
- *** The CSignature object.
- */
- struct CSignature : CObject {
- private:
- /*
- * This is the type of the last NewContext request.
- */
- unsigned long itsContextType;
- /*
- * A window managed by itsStatusManaager is created
- * when you request the default status procedure
- * by passing gSIGStatusProc to Sign or Verify
- */
- SIGStatusManager *itsStatusManager;
- public:
- void ISignature(void);
- void Dispose(void);
- /*
- * Create a new signature context. This is called
- * by SignPrepare, SignFile, VerifyPrepare, or
- * VerifyFile, or DigestPrepare if it is added.
- * RequestType is one of the following:
- * kSIGSign Signing
- * kSIGVerify Verify
- * kSIGDigest Digest
- */
- void NewContext(
- unsigned long contextType
- );
- /*
- * Fail with an appropriate error (kSIGContextPrepareErr)
- * if there is no context. (The Signature Manager will
- * fail if the context type is incorrect.
- */
- void CheckForContext(void);
- /*
- * Return the current context type, or zero
- * if there is no current context. This is needed
- * to enable/disable the ShowSigner menu option,
- * which is valid only after Verify or VerifyFile.
- */
- unsigned long GetContextType(void);
- /*
- * SignPrepare initializes the signature process.
- * Call it after the data has been created, and
- * you are ready to sign it. The parameters are
- * used as follows:
- * signerFile The file specification structure
- * for the user's signer file. If
- * NULL, the function opens the
- * previously-used signer file,
- * or displays a Standard File
- * dialog box to let the user
- * choose a signer file.
- * prompt The prompt string displayed
- * in the Standard File dialog
- * box. Pass "\p" to use the
- * default prompt string.
- * Note: if the user cancels the signature
- * request, SignPrepare will fail with error
- * code kSIGUserCanceled. SignPrepare will
- * create a new context if none is established.
- * It returns the size of the signature record.
- */
- Size SignPrepare(
- const FSSpec *signerFile,
- ConstStr255Param prompt
- );
- /*
- * Show the entire distinguished name of the signer
- * of a block of data. Call only after successfully
- * verifying a signature. prompt is the message
- * you want displayed, if "\p", ShowSigner displays
- * "Verification Successful"
- */
- void ShowSigner(
- ConstStr255Param prompt
- );
- /*
- * Get the signer information for a signature.
- * This is only valid after verification.
- */
- void GetSignerInfo(
- SIGSignerInfo *signerInfo
- );
- /*
- * Get information about a specific certificate.
- * Returns TRUE if successful, FALSE if the
- * certIndex was outside the allowable range.
- * Fails on other errors.
- */
- Boolean GetCertInfo(
- unsigned long certIndex,
- SIGCertInfo *certInfo
- );
- /*
- * Get information about a specific attribute of
- * a distinguished name in a specific certificate
- * of a signature. Returns TRUE if successful,
- * FALSE if the certIndex was outside the allowable
- * range. Fails on other errors
- */
- Boolean GetCertNameAttributes(
- unsigned long certIndex,
- unsigned long attributeIndex,
- SIGNameAttributesInfo *attributeInfo
- );
- protected:
- /*
- * This method is used to initialize the default
- * status procedure. It is called if the caller
- * specifies gSIGStatusProc in a call to Sign
- * or Verify. Application programs do not call
- * this directly: it is needed only by CSignature,
- * CSignedObject, and CSignedDataFile methods.
- */
- void InitDefaultStatusProc(
- ConstStr255Param actionString,
- ConstStr255Param objectString
- );
- /*
- * Delete the dialog used by the built-in status
- * procedure. Application programs do not call
- * this directly.
- */
- void DisposeDefaultStatusProc(void);
- };
-